home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Periodicals / develop / develop 10 code / GWorld Drawing / GWorld Routines / RedGreenInvert.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-08  |  1.3 KB  |  49 lines  |  [TEXT/KAHL]

  1.  
  2. /* 
  3. ** RedGreenInvert walks a 32-bit GWorld and inverts the red and green channels.
  4. */
  5.  
  6. #include "DemoRoutines.h"
  7.  
  8. void RedGreenInvert( GWorldPtr src )
  9. {
  10. PixMapHandle    srcPixMap;
  11. short            srcRowBytes;
  12. long            *srcBaseAddr;
  13. long            *srcAddr1;
  14. short            mmuMode;
  15. short            row, column;
  16. short            width;
  17. short            height;
  18. GDHandle    oldGD;
  19. GWorldPtr    oldGW;
  20.  
  21.     srcPixMap = GetGWorldPixMap ( src );
  22.  
  23.     if( LockPixels ( srcPixMap ) ) 
  24.     {
  25.         GetGWorld(&oldGW,&oldGD);
  26.  
  27.         srcBaseAddr = (long *) GetPixBaseAddr ( srcPixMap );    /* get the address of the pixmap */
  28.         srcRowBytes = (**srcPixMap).rowBytes & 0x7fff;            /* get the row increment */
  29.         width = (**srcPixMap).bounds.right-(**srcPixMap).bounds.left;
  30.         height = (**srcPixMap).bounds.bottom-(**srcPixMap).bounds.top;
  31.     
  32.         mmuMode = true32b;
  33.          SwapMMUMode ( &mmuMode );                        /* set the MMU to 32-bit mode */
  34.         for ( row = 0; row < height; row++ ) 
  35.         {
  36.             srcAddr1 = srcBaseAddr;
  37.             for ( column = 0; column < width; column++ ) 
  38.             {
  39.                 *srcAddr1 ^= 0x00ffff00;    /* invert the red and green */
  40.                 srcAddr1++;                    /* bump to next pixel */
  41.             }
  42.     
  43.             srcBaseAddr = (long *) ( (char *) srcBaseAddr + srcRowBytes );    /* go to the next row */
  44.         }
  45.          SwapMMUMode ( &mmuMode );                        /* restore the previous MMU mode */
  46.         UnlockPixels ( srcPixMap );                        /* unlock the pixmap */
  47.     }
  48. }
  49.